<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>源辰租房</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/nprogress.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
    <link rel="apple-touch-icon-precomposed" href="images/icon/icon.png">
    <link rel="shortcut icon" href="images/icon/favicon.ico">
    <script src="js/jquery-2.1.4.min.js"></script>
    <script src="js/nprogress.js"></script>
    <script src="js/jquery.lazyload.min.js"></script>

    <script src="https://unpkg.com/vue@2.7.14/dist/vue.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="js/login.js"></script>
    <script src="js/tenant.js"></script>
</head>
<body class="user-select">
<div id="app">
     <template>
            <el-table
                    class="el-table"
                    :data="tableData"
                    style="width: 100%">
                <el-table-column
                        prop="id"
                        label="举报编号"
                        width="100">
                </el-table-column>
                <el-table-column
                        prop="user"
                        label="举报者"
                        width="120">
                </el-table-column>
                <el-table-column
                        prop="reported"
                        label="被举报者"
                        width="120">
                </el-table-column>
                <el-table-column
                        prop="houseName"
                        label="举报房源"
                        width="150">
                </el-table-column>
                <el-table-column
                        prop="content"
                        label="举报内容"
                        width="180">
                </el-table-column><el-table-column
                        prop="time"
                        label="举报时间"
                        width="150">
                </el-table-column>
                <el-table-column
                        label="操作">
                    <template slot-scope="scope">
                    <el-row>
                        <div>
                            <el-button type="danger" disabled v-if="scope.row.state==2">已驳回</el-button>
                            <el-button type="success" disabled v-if="scope.row.state==1">已通过</el-button>
                        </div>
                        <el-button v-show="scope.row.state==0" type="primary" @click="judge(scope.row.id,2)">驳回</el-button>
                        <el-button v-show="scope.row.state==0" type="primary" @click="judge(scope.row.id,1)">通过</el-button>
                    </el-row>
                    </template>
                </el-table-column>
            </el-table>
        </template>
</div>
<script>
    var v = new Vue({
        el: "#app",
        created(){
            this.initInfo();
        },
        data:{
            tableData: [],
        },
        methods:{
            judge(id,state){
                axios.get("/TN-USER/user/report/judge?id="+id+"&state="+state).then(res=>{
                    if (res.data.code){
                        this.$message(res.data.msg);
                        this.initInfo();
                    }
                })
            },
            initInfo(){
                axios.get("/TN-USER/user/report/get").then(res=>{
                    if (res.data.code){
                        this.tableData=res.data.data;
                        for (let i = 0; i < this.tableData.length; i++) {
                            this.tableData[i].user=this.tableData[i].userName+'(id='+this.tableData[i].userId+')';
                            this.tableData[i].reported=this.tableData[i].reportedName+'(id='+this.tableData[i].reporterId+')';
                            this.tableData[i].time=this.tableData[i].time.substring(0,10);
                        }
                    }
                })
            }
        }
    })
</script>

<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.ias.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>